<template>
  <div class="page-container">
    <!-- 搜索区域 -->
    <div class="search-bar">
      <el-form :inline="true" :model="searchForm" class="search-form">
        <el-form-item label="学员姓名">
          <el-input
            v-model="searchForm.name"
            placeholder="请输入"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="手机号">
          <el-input
            v-model="searchForm.phone"
            placeholder="请输入"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="分班">
          <el-select
            v-model="searchForm.class"
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="item in classOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleSearch">搜索</el-button>
          <el-button @click="handleReset">重置</el-button>
        </el-form-item>
      </el-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="action-buttons">
      <el-button>批量分班</el-button>
      <el-button>导出手机号</el-button>
      <el-button>导出学员数据</el-button>
      <el-button>导出分班数据</el-button>
      <el-button type="primary">导入学员</el-button>
      <el-button type="primary">+ 添加学员</el-button>
    </div>

    <!-- 表格区域 -->
    <div class="table-container">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column prop="name" label="学员姓名"></el-table-column>
        <el-table-column prop="phone" label="手机号"></el-table-column>
        <el-table-column prop="class" label="分班"></el-table-column>
        <el-table-column prop="exerciseCount" label="题库练习次数"></el-table-column>
        <el-table-column prop="exerciseTime" label="题库练习时长（小时）"></el-table-column>
        <el-table-column prop="examCount" label="模拟考试次数"></el-table-column>
        <el-table-column prop="examScore" label="模拟考试平均分"></el-table-column>
        <el-table-column prop="courseProgress" label="在线课程完成进度"></el-table-column>
        <el-table-column prop="watchTime" label="看课时长（小时）"></el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-link size="mini">分班</el-link>
            <el-link size="mini" type="danger">删减</el-link>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <!-- 分页区域 -->
    <div class="pagination-container">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  name: 'StudentManagement',
  data() {
    return {
      // 搜索表单数据
      searchForm: {
        name: '',
        phone: '',
        class: ''
      },
      // 分班下拉选项
      classOptions: [
        { label: '一班', value: '一班' },
        { label: '二班', value: '二班' },
        { label: '三班', value: '三班' }
      ],
      // 表格数据
      tableData: [
        {
          name: 'XXX',
          phone: '15666666666',
          class: '一班',
          exerciseCount: 2,
          exerciseTime: 2.5,
          examCount: 3,
          examScore: 88,
          courseProgress: '30%',
          watchTime: 2.5
        }
      ],
      // 分页数据
      currentPage: 4,
      pageSize: 10,
      total: 100
    };
  },
  methods: {
    // 搜索按钮点击事件
    handleSearch() {
      console.log('搜索条件：', this.searchForm);
    },
    // 重置按钮点击事件
    handleReset() {
      this.searchForm = {
        name: '',
        phone: '',
        class: ''
      };
    },
    // 每页条数改变事件
    handleSizeChange(val) {
      this.pageSize = val;
      console.log(`每页 ${val} 条`);
    },
    // 当前页改变事件
    handleCurrentChange(val) {
      this.currentPage = val;
      console.log(`当前页: ${val}`);
    }
  }
};
</script>

<style scoped>
.page-container {
  padding: 20px;
}
.search-bar {
  margin-bottom: 20px;
}
.action-buttons {
  margin-bottom: 20px;
}
.action-buttons .el-button {
  margin-right: 10px;
}
.table-container {
  margin-bottom: 20px;
}
.pagination-container {
  text-align: right;
}
</style>
